//
//  YWTabBarController.m
//  yawen截图
//
//  Created by yawen on 16/3/2.
//  Copyright © 2016年 yawen. All rights reserved.
//

#import "YWTabBarController.h"
#import "YWScreenshotTableViewController.h"
#import "YWAdressTableViewController.h"
#import "YWMeTableViewController.h"


@interface YWTabBarController ()

@end

@implementation YWTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    YWScreenshotTableViewController *screenVC = [[YWScreenshotTableViewController alloc]init];
    [self addChildVCWith:screenVC title:@"截图" nmlImgName:@"cut_normal" selImgName:@"cut_pressed"];
    
    YWAdressTableViewController *addressVC = [[YWAdressTableViewController alloc]init];
    [self addChildVCWith:addressVC title:@"通讯录" nmlImgName:@"icon_Address_Book_normal" selImgName:@"icon_Address_Book_pressed"];
    
    YWMeTableViewController *meVC = [[YWMeTableViewController alloc]init];
    [self addChildVCWith:meVC title:@"我的" nmlImgName:@"icon_me_normal" selImgName:@"icon_me_pressed"];

}

-(void)addChildVCWith:(UIViewController *)vc title:(NSString *)title nmlImgName:(NSString *)nmlImgName selImgName:(NSString *)selImgName {
    
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
    [self addChildViewController:nav];
    
    //设置标题
    nav.tabBarItem.title = title;
    
    
    //设置普通状态图片
    nav.tabBarItem.image = [UIImage imageNamed:nmlImgName];
    
    //设置高亮
    // 默认情况下，tabbar会选中的图片进行渲染成蓝色
    UIImage *selImg = [UIImage imageNamed:selImgName];
    selImg = [selImg imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    nav.tabBarItem.selectedImage = selImg;
    
    
    NSDictionary *dic = @{
                          NSForegroundColorAttributeName: [UIColor colorWithRed:29/255.0 green:193/255.0 blue:37/255.0 alpha:1],
                          
                          };
    
    [nav.tabBarItem setTitleTextAttributes:dic forState:UIControlStateSelected];
    
    
    
//    controller.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.orangeColor()], forState: UIControlState.Selected)
    
    
}



@end
